Skip to content

fix(fields): an untyped repeater edits its stored rows as JSON in the record form - #29269

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-mm0rzm
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-mm0rzm

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #29177

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:对象上的 repeater 字段(无类型 JSON 数组)在记录编辑表单里改用 JSON 编辑器显示和编辑,与旁边的 composite、record 一致;原来走的是明细行网格,没有列,只画出编号行。
  • 为什么改:网格只画声明过的列,而 spec 规定 repeater 没有列,所以已存的 [{label:'one',qty:1},…] 在表单里看不到、也改不了。另一条路(按行的键推导列)实测会把 qty 存成字符串 "5"、把嵌套对象显示为 [object Object],会丢数据,所以没选。
  • 风险与回滚:只改别名表一行;repeater 在记录表单和 Studio 表单画布上不再占满整行(JSON 编辑器是普通宽度,与 composite 相同)。声明了列的明细行网格不变;行内编辑本来就排除 repeater,仍然排除。回滚即 revert 本 PR。
  • 先看:ui/packages/fields/src/field-type-alias.ts(repeater 那一行),ui/packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx,ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.test.tsx(宽度用例改指向)。
  • 两分钟验证:cd ui && pnpm exec vitest run packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx,预期 4 个用例全绿;或在 showcase 的 Field Zoo「Specimen — Full」点 Edit,看到 "Repeater (embedded array)" 显示两行 JSON。
  • 需要你做的:无,席位落地。

What changes

@objectstack/spec declares repeater an untyped array of embedded JSON objects: FieldSchema has no sub-field or column member, the strict field schema refuses columns on it by name, and the field/embedded-sub-fields lint reports one. The form's alias table (mapFieldTypeToFormType in ui/packages/fields/src/field-type-alias.ts) still sent it to the line-items grid (field:grid). GridField draws only declared columns (allColumns = cfg.columns || []), so a stored repeater showed numbered rows with Duplicate and Remove and no cell, and Add line appended an empty object.

The one table row changes: repeater: 'field:grid' becomes repeater: 'field:object', the JSON editor (ObjectField) that composite, record and json already use. The edit form now shows the stored array as pretty-printed JSON, an edit saves an array of objects (never a string), and unparsable text is refused before the save. GridField.tsx is not touched.

Why the JSON editor and not derived columns. The card offered both, and both were measured. Driving GridField with columns derived from the row keys (the shape a derived-columns fix would hand it) on rows {label:'one',qty:1,meta:{color:'red'}} and {label:'two',qty:2,extra:true}: the meta cell read [object Object], the extra cell read the text true, and changing the qty cell to 5 emitted qty: "5", a string. A derived grid therefore loses edits (type drift on every touched cell) or has to be read-only, and either way cannot show nested values. The JSON editor round-trips any value the spec allows, and it is the face the other two untyped containers already have, so the three behave alike.

What else moves, by consequence.

  • Layout: field:grid is in the form's WIDE_FIELD_TYPES, field:object is not. A repeater is now laid out at normal width in the record form and on the Studio form canvas, like composite. The canvas resolves width through the same alias table, so the two still agree. ObjectFormDesigner.test.tsx case "spans a repeater field full-row" pinned the old width; it is repointed to assert the canvas matches the runtime resolution (field:object, not full-row). The seat accepted this file before it was edited.
  • Inline editing: unchanged. repeater stays excluded (object and grid are both in INLINE_EXCLUDED_FIELD_TYPES); FieldEditWidget.test.ts "the structured/computed spec spellings are closed corruption paths" is green unchanged.
  • Read side: unchanged. Record detail and the list cell (RepeaterCellRenderer, the row count) do not read the form alias.
  • A comment in autoLayout.wideSpelling.test.ts that described the repeater/grid width asymmetry as open is updated; that asymmetry no longer exists.

Repeaters that declare columns. None exist to lose their grid: git grep for type: 'repeater' across the repo (examples, showcase, apps, tests, docs) and objectstack-ai/hotcrm found no object field that declares columns. The only hit carrying columns is the lint test that proves such a field is refused. The metadata-form repeater rows in packages/spec/src/**/*.form.ts are a different surface (Studio's SchemaForm RepeaterField), which does not read this alias table.

Tests

  • New ui/packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx, driven through the record Edit dialog (ModalForm, real registered widgets, a click on the real Update button), with the card's value [{label:'one',qty:1},{label:'two',qty:2}] and no columns:
    1. the field shows "one", "two", 1 and 2, and no line-items grid;
    2. an edit saves f_repeater as an array of objects with numeric qty, never a string;
    3. an untouched save never writes the field as text;
    4. control: a line-items grid that declares its columns still draws one input per column and writes a typed cell (qty: 4).
  • ObjectFormDesigner.test.tsx: the repeater width case is repointed as above.

Acceptance notes

  • Ablation. Restoring repeater: 'field:grid' through scripts/ablation-replace.mjs (anchor 1 -> 0) turned cases 1-3 red; the control stayed green. Restored: blob == HEAD, git diff HEAD empty.
  • Real browser, showcase field zoo: MEASURED. Fresh showcase backend (objectstack dev --seed-admin --fresh) plus the Console Vite dev server on source, "Specimen — Full", Edit. With the alias row reverted: a full-width grid with header "#", rows 1 and 2 with Duplicate and Remove, a ghost row 3, Add line, no cell content. With this change: the field shows the two rows as JSON beside the composite and record editors; replacing the text with [{"label":"one","qty":5},{"label":"three","qty":3}] and clicking Update stored exactly that array of objects (read back through GET /api/v1/data/showcase_field_zoo/ID). Screenshots are kept with the card thread.
  • No spec change. The untyped shape stands as ruled on Object fields: repeater / composite cannot declare typed sub-fields, so they are untyped JSON in forms and flows #25681.

Verification

Gate and suite readings at head 92297c74; main 74a19dd8 was then merged (head 7393c5a0). The merged commits touch ui/packages/plugin-form section fields and packages/spec record-page schemas, nothing this diff reads, and the scoped files below were re-run on 7393c5a0.

fields suite: 293 files green

cd ui && pnpm exec vitest run --maxWorkers=2 FILES, under os-verify-lock, in three parts of packages/fields' 293 test files: 95 passed 1 skipped (1729 tests), 102 passed (1750 tests), 95 passed (920 tests); each VERDICT command-exit 0.

consumers and final-head re-run
  • The new test, ModalForm.jsonField-11448, the designer, autoLayout and inline-edit coverage tests, form-field-widget-namespace, the data-list, detail and widget-dom-leak-sweep files that type a field repeater: 15 files, 500 tests passed.
  • On 7393c5a0 after the merge: 10 files, 278 tests passed.
type-check and lint
  • pnpm exec turbo run type-check --concurrency=2 --filter=@object-ui/fields --filter=@object-ui/plugin-form --filter=@object-ui/plugin-detail: Tasks 50 successful, 50 total (each runs tsc -p tsconfig.test.json too).
  • pnpm exec eslint on the four touched source/test files: exit 0, 0 errors (6 no-explicit-any warnings on test casts, the sibling JSON-field test's shape).
  • pnpm check:new-line-citations (from ui/): 0 new citations.
derived gates: 34 of 34 exit 0

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 34 commands (the same list on the merged head); each ran and exited 0, including node scripts/check-sdui-manifest.mjs, the changeset gates, pnpm check:type-check-debt (0 raw tsc errors above ledger) and pnpm --dir ui exec vitest run scripts/ (168 files passed; check-hand-rolled-comment-mask.test.ts timed out once at 15 s beside a locked run and passed alone, 22 of 22). --ran reconciliation: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.


Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m

席位核对 · ACCEPT · 2026-11-02T11:09Z

Head-sha: 7393c5a0396d20b4fff1a5125bc6c9f8662d6e02

  • Shape: draft → main, Fixes #29177 in the body only. 5 files, +211 / −14 (225 lines ≤ 3000). No governed path: check-governed-merges --pr 29269 reports NOT governed. Clause-②: no and Metadata-protocol: none are line-initial in the body and the changeset, as claimed (6573672277). The changeset is patch for @object-ui/fields.
  • Contract review: none owed (Clause-②: no; no exported prop or type changes, no metadata key; the spec's untyped repeater shape, ruled on Object fields: repeater / composite cannot declare typed sub-fields, so they are untyped JSON in forms and flows #25681, is untouched).
  • File surface: inside the claim plus two accepted test repoints: field-type-alias.ts (one alias row and its comment), the new ModalForm.untypedRepeater test, ObjectFormDesigner.test.tsx ("spans a repeater full-row" repointed: field:object is not in WIDE_FIELD_TYPES, so canvas and runtime still agree), a comment in autoLayout.wideSpelling.test.ts, and the changeset. GridField.tsx is untouched.
  • Read in the diff: repeater maps to field:object, the JSON editor composite, record and json already use: the stored array shows as pretty-printed JSON, an edit saves an array of objects, unparsable text is refused before save. Inline editing stays excluded (object is in the inline exclusion set). A grid that declares columns is a different type and unchanged.
  • Measured premise / alternatives (dev): derived read-only columns were measured lossy (qty → "5", nested → [object Object]), so the JSON editor was chosen. No object-level repeater declares columns in objectstack or hotcrm (only the lint test proving the strict schema refuses it), so no grid-keeping branch is needed.
  • Tests (dev): new ModalForm.untypedRepeater 4 cases through the real Edit dialog, including a declared-columns grid control; ablation (alias back to field:grid) reds 3 of 4 with the control green, restored. Fields suite 293 files; consumers 15 files / 500 tests. Derived gates 34 of 34.
  • Measured (dev): on a fresh showcase, the field zoo's repeater showed bare rows before and its JSON rows after, and Update stored an array of objects.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. mergeable_state is clean.
  • Accepted consequence: the field is no longer full-row on the record form and the Studio canvas (normal width, like composite); stated in the changeset.
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #29177 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 11:10
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 11:10
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 18a7f60 Nov 2, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-mm0rzm branch November 2, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record form: an untyped repeater field draws its rows with no columns, so the stored row content is invisible and cannot be edited

1 participant